home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 05 Tactical Issues / 03 vanderSterren / Listing1.cpp next >
Encoding:
Text File  |  2001-12-09  |  1.1 KB  |  46 lines

  1. /* Copyright (C) William van der Sterren, 2001. 
  2.  * All rights reserved worldwide.
  3.  *
  4.  * This software is provided "as is" without express or implied
  5.  * warranties. You may freely copy and compile this source into
  6.  * applications you distribute provided that the copyright text
  7.  * below is included in the resulting source code, for example:
  8.  * "Portions Copyright (C) William van der Sterren, 2001"
  9.  */
  10.  
  11. // Left code portion from Figure 1
  12. void SoloAI::Think() {
  13.     CombatSituation* sit = GetSituation();
  14.     sit->Observe();
  15.  
  16.  
  17.     for each available action {
  18.         if( action.IsApplicable(sit) )
  19.         {
  20.             determine value of action in sit;
  21.             if better than best action, 
  22.                 make best action
  23.         }
  24.     }
  25.  
  26.     Execute best action();
  27. }
  28.  
  29. // Right code portion from Figure 1
  30. void SquadMemberAI::Think() {
  31.     CombatSituation* sit = GetSituation();
  32.     Sit->Observe();
  33.     sit->ProcessTeamIntentions();
  34.     sit->ProcessTeamObservations();
  35.     for each available action {
  36.         if( action.IsApplicable(sit) )
  37.         {
  38.             determine value of action in sit;
  39.             if better than best action, 
  40.                 make best action
  41.         }
  42.     }
  43.     nearbySqdMembers->AnnounceActn();
  44.     Execute best action();
  45. }
  46.